package com.atguigu.lease.web.app.controller.history;


import com.atguigu.lease.common.context.LoginUserContext;
import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.web.app.service.BrowsingHistoryService;
import com.atguigu.lease.web.app.vo.history.HistoryItemVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name = "浏览历史管理")
@RequestMapping("/app/history")
public class BrowsingHistoryController {

	@Autowired
	private BrowsingHistoryService browsingHistoryService;

	// 查询浏览历史之前应该先添加历史记录
	// 查询浏览历史的时候 除了获取浏览历史记录外
	// 给后端传参一下用户的id以便列出当前所属用户的浏览历史记录
	@Operation(summary = "获取浏览历史")
	@GetMapping("pageItem")
	private Result<IPage<HistoryItemVo>> page(@RequestParam long current, @RequestParam long size) {
		IPage<HistoryItemVo> iPage =  browsingHistoryService.pageInfo(new Page<HistoryItemVo>(current,size), LoginUserContext.getLoginUser().getUserId());
		return Result.ok(iPage);
	}

}
